//
//  HomepageTravelCell.m
//  Tour
//
//  Created by hesiyao on 16/3/8.
//  Copyright © 2016年 张中烨. All rights reserved.
//

#import "HomepageTravelCell.h"
#define CONTENTWIDTH self.contentView.frame.size.width
#define CONTENTHEIGHT self.contentView.frame.size.height

@implementation HomepageTravelCell

#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 图片
        self.photo = [[UIImageView alloc]init];
        //        _photo.backgroundColor = [UIColor redColor];
        self.photo.contentMode = UIViewContentModeScaleAspectFill;
        self.photo.clipsToBounds = YES;
        [self.contentView addSubview:_photo];

        
        // 标题
        self.title = [[BaseLabel alloc]init];
        //        self.title.backgroundColor = [UIColor cyanColor];
        _title.numberOfLines = 0;
        _title.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_title];

        
        // 用户名
        self.username = [[BaseLabel alloc]init];
//                self.username.backgroundColor = [UIColor whiteColor];
        _username.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_username];

        
        // 查看人数
        self.views = [[BaseLabel alloc]init];
        //        self.views.backgroundColor = [UIColor blueColor];
        _views.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_views];

        
        // 回复
        self.replys = [[BaseLabel alloc]init];
        //        self.replys.backgroundColor = [UIColor magentaColor];
        _replys.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_replys];

        
        // 回复 image
        self.replysimg = [[UIImageView alloc]init];
        self.replysimg.image = [UIImage imageNamed:@"replys"];
        [self.contentView addSubview:_replysimg];

        
        // 查看 image
        self.viewimg = [[UIImageView alloc]init];
        self.viewimg.image = [UIImage imageNamed:@"views"];
        [self.contentView addSubview:_viewimg];

    }
    return self;
}

#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    // 图片
    _photo.frame = CGRectMake(10, 10, 100, 80);
    CGRect f = _photo.frame;
    // 标题
    _title.frame = CGRectMake(f.origin.x + 100 + 10, 10, CONTENTWIDTH -f.size.width - 10 - 10, 40);
    CGRect f1 = _title.frame;
    // 用户名
    _username.frame = CGRectMake(f1.origin.x , f1.origin.y + 40, 100, 15);
    CGRect f2 = _username.frame;
    // 评论
    _replysimg.frame = CGRectMake(f2.origin.x, CONTENTHEIGHT - 20, 15, 15);
    _replys.frame = CGRectMake(f2.origin.x + 15 + 5, CONTENTHEIGHT - 20, 50, 15);
    // 查看
    _viewimg.frame =CGRectMake(f2.origin.x + 15 + 5 + 15 + 40, CONTENTHEIGHT - 20, 15, 15);
    _views.frame = CGRectMake(self.viewimg.frame.origin.x + 15 + 5, CONTENTHEIGHT - 20, 50, 15);
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
